package clientApp;

import game.map.MapInteractionServer;

import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JRadioButton;

/**
 *
 * @author Gabriel
 */
public class MasterPanel1 extends javax.swing.JPanel {

	private static final long serialVersionUID = 1L;
	
	private ArrayList<String> names = new ArrayList<String>();
	private List<JRadioButton> buttons = new ArrayList<JRadioButton>();
	
	private MapInteractionServer interactMaster;
	
    /** Creates new form MasterPanel1 
     * @param interactMaster */
    public MasterPanel1() {
        initComponents();
    }

    public void initPlayersNames()
    {
    	for(int i = 0; i < names.size(); i++) {
    		if (names.get(i).equals("Open Slot")) {
    			buttons.get(i).setVisible(false);
    			buttons.get(i).setEnabled(false);
    		} else
    			buttons.get(i).setText(names.get(i));
    	}
    }
     
    public ArrayList<String> getNames() {
		return names;
	}

	public void setNames(ArrayList<String> names) {
		this.names = names;
	}
	
//	public List<MapUnit> getSelectedCharacters(MapInteraction interact) {
//		List<MapUnit> mus = interact.getPlayers();
//		if (jRBPlayer1.isSelected())
//			
//		for (int i = mus.size(); i > 0; i--) {
//			if (buttons.get(i))
//		}
//	}

	/** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jBItemAdd = new javax.swing.JButton();
        jTFRemoveItem = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jTFItemID = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jTFDragUnit = new javax.swing.JButton();
        jTFPauseGame = new javax.swing.JButton();
        jTFCHangeHp = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();
        jBTeleportPlayers = new javax.swing.JButton();
        jBSkillTest = new javax.swing.JButton();
        jRBPlayer1 = new javax.swing.JRadioButton();
        jRBPlayer2 = new javax.swing.JRadioButton();
        jRBPlayer3 = new javax.swing.JRadioButton();
        jRBPlayer4 = new javax.swing.JRadioButton();
        jRBPlayer5 = new javax.swing.JRadioButton();
        
        buttons.add(jRBPlayer1);
        buttons.add(jRBPlayer2);
        buttons.add(jRBPlayer3);
        buttons.add(jRBPlayer4);
        buttons.add(jRBPlayer5);

        setBackground(new java.awt.Color(0, 0, 102));

        jPanel1.setBackground(new java.awt.Color(0, 0, 102));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Item Menu", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12), new java.awt.Color(255, 255, 255))); // NOI18N

        jBItemAdd.setText("Add Item");
        

        jTFRemoveItem.setText("Remove Item");
        jTFRemoveItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBRemoveItemActionPerformed(evt);
            }
        });
        

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Item ID:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jTFItemID, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
                    .addComponent(jBItemAdd, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
                    .addComponent(jTFRemoveItem, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTFItemID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jBItemAdd)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTFRemoveItem)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBackground(new java.awt.Color(0, 0, 102));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Map Interactions", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12), new java.awt.Color(255, 255, 255))); // NOI18N

        jTFDragUnit.setText("Drag Unit");
        

        jTFPauseGame.setText("Pause Game");
        

        jTFCHangeHp.setText("Change HP");
        
        jBTeleportPlayers.setText("Teleport");        

        jBSkillTest.setText("Skill Test");
        

        jRBPlayer2.setText("PlayerName");

        jRBPlayer1.setText("PlayerName");

        jRBPlayer3.setText("PlayerName");

        jRBPlayer4.setText("PlayerName");

        jRBPlayer5.setText("PlayerName");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTFPauseGame, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
                    .addComponent(jTFDragUnit, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jTFCHangeHp, javax.swing.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jBTeleportPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
                    .addComponent(jBSkillTest, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
                    .addComponent(jRBPlayer2, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jRBPlayer3, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jRBPlayer4, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jRBPlayer5, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jRBPlayer1, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jRBPlayer1, jRBPlayer2, jRBPlayer3, jRBPlayer4, jRBPlayer5});

        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTFPauseGame)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTFDragUnit)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTFCHangeHp)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                .addComponent(jRBPlayer1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jRBPlayer2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jRBPlayer3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jRBPlayer4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jRBPlayer5)
                .addGap(12, 12, 12)
                .addComponent(jBSkillTest)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jBTeleportPlayers)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jBRemoveItemActionPerformed(ActionEvent evt) {
    	interactMaster.setTool(MapInteractionServer.Tools.REMOVE_ITEM);
	}
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JButton jBItemAdd;
    public javax.swing.JButton jBSkillTest;
    public javax.swing.JButton jBTeleportPlayers;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    public javax.swing.JRadioButton jRBPlayer1;
    public javax.swing.JRadioButton jRBPlayer2;
    public javax.swing.JRadioButton jRBPlayer3;
    public javax.swing.JRadioButton jRBPlayer4;
    public javax.swing.JRadioButton jRBPlayer5;
    public javax.swing.JButton jTFCHangeHp;
    public javax.swing.JButton jTFDragUnit;
    private javax.swing.JTextField jTFItemID;
    public javax.swing.JButton jTFPauseGame;
    public javax.swing.JButton jTFRemoveItem;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration//GEN-END:variables

	public void setInteract(MapInteractionServer interactMaster) {
		this.interactMaster = interactMaster;
	}
}

